package co.fitstart.weapp.api.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.course.round.CourseRound;
import co.fitstart.entity.user.User;
import co.fitstart.entity.user.bwh.BwhRecord;

/**
 * 
 * @author haiyan_xiao
 *
 */
@Dao("hibernate")
public interface BwhRecordDao {

    /**
     * 
     * @param courseRound
     * @return
     */
    @Query("FROM BwhRecord WHERE disabled = false AND courseRound = :courseRound AND bust IS NOT NULL AND waist IS NOT NULL AND hips IS NOT NULL ORDER BY createTime ASC")
    public List<BwhRecord> list(@Variable("courseRound") CourseRound courseRound);

    /**
     * 
     * @param courseRound
     * @return
     */
    @Query("FROM BwhRecord WHERE disabled = false AND courseRound = :courseRound AND week IS NOT NULL")
    public List<BwhRecord> listForResultReport(@Variable("courseRound") CourseRound courseRound);

    /**
     * 
     * @param user
     * @return
     */
    @Query("FROM BwhRecord WHERE disabled = false AND user = :user ORDER BY createTime ASC")
    public List<BwhRecord> list(@Variable("user") User user);

    /**
     * 
     * @param courseRound
     * @return
     */
    @Query("FROM BwhRecord WHERE disabled = false AND courseRound = :courseRound ORDER BY createTime DESC")
    public BwhRecord loadLatest(@Variable("courseRound") CourseRound courseRound);
}
